package io.finer.erp.jeecg.finance.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.api.vo.Result;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import io.finer.erp.jeecg.bas.entity.SalesDelivery;
import io.finer.erp.jeecg.bas.entity.SalesDeliveryEntry;
import io.finer.erp.jeecg.bas.vo.SalesDeliveryOrEntryVO;
import io.finer.erp.jeecg.finance.dto.FinaReceiptAddDto;
import io.finer.erp.jeecg.finance.dto.FinaReceiptDto;
import io.finer.erp.jeecg.finance.dto.FinaReceiptPrintDTO;
import io.finer.erp.jeecg.finance.dto.ZrkShoporderDto;
import io.finer.erp.jeecg.finance.entity.FinaReceipt;
import io.finer.erp.jeecg.finance.vo.DeliverDetalidVO;
import io.finer.erp.jeecg.finance.vo.DeliverySumVO;
import io.finer.erp.jeecg.finance.vo.DeliverySummaryVO;
import io.finer.erp.jeecg.finance.vo.FinaReceiptPage;
import io.finer.erp.jeecg.finance.vo.FinaReceiptPageSumVO;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSKVo;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSumPage;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSumVO;
import io.finer.erp.jeecg.finance.vo.FinaReceiptVO;
import io.finer.erp.jeecg.finance.vo.ReceiptSumVO;
import io.finer.erp.jeecg.finance.vo.ReceiptVO;
import io.finer.erp.jeecg.stock.entity.StkIoBill;
import io.finer.erp.jeecg.stock.entity.StkIoBillEntry;

/**
 * @Description: 收款表
 * @Author: jeecg-boot
 * @Date:   2021-03-22
 * @Version: V1.0
 */
public interface IFinaReceiptService extends IService<FinaReceipt> {

    /**
     * 应收/已收统计列表
     * @param page
     * @return
     */
    List<FinaReceiptPage> getPageReceipt(FinaReceiptVO vo);
    /**
    * 应收已收列表金额合计
    * @Author: libaow
    * @Description:
    * @DateTime: 16:20 2021/5/14
    */
    FinaReceiptPageSumVO getPageReceiptSum(
                                           String createTimeStart, String createTimeEnd,
                                           String customerName,
                                           BigDecimal receivablesEnd,
                                           BigDecimal receivablesStart,
                                           BigDecimal receivedsEnd,BigDecimal receivedsStart,
                                           BigDecimal invoicePriceStart,BigDecimal invoicePriceEnd,
                                           BigDecimal discountSumPriceStart,BigDecimal discountSumPriceEnd);




    /**
     * 收款单列表
     * @param page
     * @return
     */
    Page<FinaReceiptSKVo> getPageReceiptSK(IPage<FinaReceiptSKVo> page,
                                           Date createTimeStart,
                                           Date createTimeEnd,
                                           String customerName,
                                           String cashType,
                                           HttpServletRequest request);
    /**
     * 收款单汇总列表
     * @param page
     * @return
     */
    Page<FinaReceiptSumPage> getPageReceiptSumPage(IPage<FinaReceiptSumPage> page,
                                           String createTimeStart,
                                           String createTimeEnd,
                                           String customerName);

    /**
    * @Author: libaow
    * @Description: 发货单应收已收列表
    * @DateTime: 14:54 2021/5/10
    * @Params: []
    * @Return []
    */
    Map<String, Object> getDeliveryOrEntry(String receiptType,String customerId,String createTimeStart,String endTime,
                                                    Integer salesType,String code,String productName,
                                                    Integer viceQtyStart,Integer viceQtyEnd,BigDecimal qtyStart,
                                                    BigDecimal qtyEnd,BigDecimal unitPriceStart,BigDecimal unitPriceEnd,
                                                    BigDecimal totalPriceStart,BigDecimal totalPriceEnd,BigDecimal totalAmountStart,
                                                    BigDecimal totalAmountEnd,BigDecimal hxPriceStart,BigDecimal hxPriceEnd,
                                                    BigDecimal zkPriceStart,BigDecimal zkPriceEnd,BigDecimal qkPriceStart,
                                                    BigDecimal qkPriceEnd,String remark);


    boolean marchFlat(FinaReceipt finaReceipt);

        /*
         * 创建应收---销售出库
         * @author libaow
         * @date 2021/4/29 10:42
         * @param stkIoBill
         * @param stkIoBillEntryList
         */
    void createReceivables(StkIoBill stkIoBill, List<StkIoBillEntry> stkIoBillEntryList);
    /*
     * 创建应收----打印发货单
     * @author libaow
     * @date 2021/4/29 10:43
     * @param salesDelivery
     * @param entries
     */
    void createReceivables1(SalesDelivery salesDelivery,List<SalesDeliveryEntry> entries);

    List<FinaReceiptDto> getReceiptExcel(String createTimeStart, String createTimeEnd,
                                         String customerName);
    FinaReceiptSumVO getamountSK(Date createTimeStart, Date createTimeEnd,
                                 String customerName, String cashType
                                 , HttpServletRequest request);

    /*
     *  根据客户id获取未核销的销售信息
     * @author libaow
     * @date 2021/4/17 16:05
     * @param finaReceipt
     * @return java.util.List<io.finer.erp.jeecg.finance.dto.ZrkShoporderDto>
     */
    List<ZrkShoporderDto> getOrder(ZrkShoporderDto finaReceipt);

    List<ZrkShoporderDto> getOrderY(ZrkShoporderDto finaReceipt);

    ReceiptSumVO getamountSum(String createTimeStart, String createTimeEnd,
                              String customerName);


    /*
     * 收款单核销
     * @author libaow
     * @date 2021/4/29 10:43
     * @param finaReceipt
     * @return boolean
     */
   boolean automaticWriteOff(FinaReceiptAddDto finaReceipt);


    List<DeliverySummaryVO> getDeliver(DeliverySummaryVO summaryVO);

    DeliverySumVO getDeliverSum(DeliverySumVO sumVO);


    List<DeliverDetalidVO> getDeliverDetali(DeliverDetalidVO detalidVO);

    List<SalesDeliveryEntry> exportDelivery(String code);
    
	/**
	 * @Description 导出收款单Excel用到的查询
	 * @param createTimeStart
	 * @param createTimeEnd
	 * @param customerName
	 * @return
	 * Create at: 2021-05-25 09:11:19
	 * @author: duany
	 * Revision:
	 *    2021-05-25 09:11:19 - first revision by duany
	 *        
	 */
	List<FinaReceiptSKVo> excelGet(Date createTimeStart, Date createTimeEnd, String customerName);
	/**
	 * @Description 收款单添加
	 * @param finaReceipt
	 * @return
	 * Create at: 2021-05-25 15:47:01
	 * @author: duany
	 * Revision:
	 *    2021-05-25 15:47:01 - first revision by duany
	 *        
	 */
	Result<?> addReceipt(FinaReceiptAddDto finaReceipt);

	/**
	 * @Description 发货单明细表
	 * @param page 
	 * @param vo
	 * @return
	 * Create at: 2021-06-04 15:22:50
	 * @author: xzs
	 * Revision:
	 *    2021-06-04 15:22:50 - first revision by xzs
	 *
	 */
	IPage<SalesDeliveryOrEntryVO> getSalesDeliveryAndEntry(Page<SalesDeliveryOrEntryVO> page, SalesDeliveryOrEntryVO vo);
	
	/**
	 * 导出（打印）对账单应收余额
	 * @Description 
	 * @param vo
	 * @return
	 * Create at: 2021-06-05 10:09:14
	 * @author: xzs
	 * Revision:
	 *    2021-06-05 10:09:14 - first revision by xzs
	 *
	 */
	FinaReceiptPrintDTO getSalesDeliveryByTime(FinaReceiptPage vo);

	/**
	 * @Description 查询客户的货单表明细
	 * @param customerId
	 * @return
	 * Create at: 2021-06-04 09:03:44
	 * @author: duany
	 * Revision:
	 *    2021-06-04 09:03:44 - first revision by duany
	 *        
	 */
	Result<?> getCustomerDelivery(String customerId);
	/**
	 * @Description 添加收款单
	 * @param vo
	 * @return
	 * Create at: 2021-06-04 16:19:51
	 * @author: duany
	 * Revision:
	 *    2021-06-04 16:19:51 - first revision by duany
	 *        
	 */
	Result<?> addReceipt(ReceiptVO vo);
	/**
	 * @Description 收款单修改
	 * @param vo
	 * @return
	 * Create at: 2021-06-07 15:52:41
	 * @author: duany
	 * Revision:
	 *    2021-06-07 15:52:41 - first revision by duany
	 *        
	 */
	Result<?> updateReceipt(ReceiptVO vo);
	
	/**
	 * @Description 查询详情
	 * @param receiptId
	 * @return
	 * Create at: 2021-06-08 15:52:28
	 * @author: duany
	 * Revision:
	 *    2021-06-08 15:52:28 - first revision by duany
	 *        
	 */
	Result<ReceiptVO> getReceiptInfo(String receiptId);
	
	/**
	 * @Description 记录客户扎帐日期
	 * @param receipt
	 * @return
	 * Create at: 2021-06-09 15:56:05
	 * @author: xzs
	 * Revision:
	 *    2021-06-09 15:56:05 - first revision by xzs
	 *
	 */
	boolean printChargeTime(FinaReceiptPage receipt);
}
